package com.zhf;

import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

/**
 * @author: 曾鸿发
 * @create: 2021-12-28 14:06
 * @description：
 **/
public class ServiceMain {

    public static void main(String[] args) throws Exception {
        // 实例化要暴露给远程的方法/接口
        SayService impl = new SayServiceImpl();
        // 开启本地服务
        SayService sayService = (SayService) UnicastRemoteObject.exportObject(impl, 666);

        // 服务注册中心
        Registry registry = LocateRegistry.createRegistry(999);

        // 注册服务
        registry.rebind("sayService", sayService);
    }
}
